package com.ganbo.redpacket.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

/**
 * 参数校验
 *
 * @author brucegan
 * @date 2019-08-08 18:36
 */

@Configuration
public class ValidatorConfig {


    @Bean
    public Validator validator() {
        ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true) //开启快速失败
                .buildValidatorFactory();
        return validatorFactory.getValidator();
    }

}
